/*
 * Copyright 2010-2012 Susanta Tewari. <freecode4susant@users.sourceforge.net>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package genomemap.cef.pui;

import cef.event.EstimateModelEvent;
import cef.event.Event;
import cef.pui.EventConstructionException;
import cef.pui.EventImpl;
import cef.pui.pob.Builder;
import commons.core.ModelEstimator;
import genomemap.cef.pui.pob.Builders_Gen;
import genomemap.data.KSA00Data;
import genomemap.model.KSA00;

import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

/**
 * Implements {@code EstimateModelKSA00Event} using the following properties.
 * <ul>
 * <li>{@code
 * genomemap.builder.KSA00Data.url = ksa00data:xml//URL }<a href="genomemap/cef/pui/pob/doc-files/ksa00-data.xml.txt">file
 * format</a>, must accompany the <a href="genomemap/cef/pui/pob/doc-files/KSA00Data.xsd.txt">schema</a></li>
 * <li>{@code genomemap.builder.KSA00Estimator.implCode = ksa00estimator:conj-gradient}</li>
 * </ul>
 *
 * @author Susanta Tewari
 * @version 1.1.0
 * @history Created on 8/13/12
 * @since 1.1.0
 */
public class EstimateModelKSA00EventImpl extends EventImpl
        implements EstimateModelEvent<KSA00, KSA00Data> {

    /** Field description */
    private final Builder<ModelEstimator<KSA00, KSA00Data, KSA00Data, ?>> estimatorBuilder;

    /**
     * @param props command properties
     *
     * @throws EventConstructionException
     */
    public EstimateModelKSA00EventImpl(final Properties props) throws EventConstructionException {

        super(props);

        super.processEventProperties(getImplementedEventInterfaces());


        // estimator builder
        estimatorBuilder = Builders_Gen.of_ModelEstimator_KSA00(props, null);
    }

    /**
     * @return estimator (algorithm) to be used
     */
    @Override
    public ModelEstimator<KSA00, KSA00Data, KSA00Data, ?> getEstimator() {
        return estimatorBuilder.build();
    }

    /**
     * List the event interfaces being implemented in their order.
     *
     * @return list of implemented event interfaces
     */
    @Override
    protected List<Class<? extends Event>> getImplementedEventInterfaces() {

        final List<Class<? extends cef.event.Event>> result = new ArrayList<>(2);

        result.add(EstimateModelEvent.class);
        result.add(Event.class);

        return result;
    }
}
